<template lang="html">
  <ul>
    <li v-for="p in products">
      {{p.title}} - {{p.price}}
      <button type="button" name="button">放入购物车</button>
    </li>
  </ul>
</template>

<script>
import shop from '../api/shop'
import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      y: 0
    }
  },
  mounted() {
    this.$store.dispatch('getAllProducts')
  },
  computed: {
    ...mapGetters({
      products: 'allProducts'
    })
  }
}
</script>

<style lang="css">
  button {
    border: solid 1px #ccc;
  }
</style>
